<?php get_header();?>
<?php get_template_part('left','menu');?>
<section>
<div class="container">
<div class="left_main" id="left_side">
	<div class="showType">
		<?php wp_bac_breadcrumb();?>
	</div>
	<div class="content_out">
	<div class="content">
	<?php if( have_posts() ) : the_post(); ?>
	<div class="perContentBox">
	<div class="contentBg">
		<div class="con_title" style="background-image:url(<?php echo get_template_directory_uri();?>/images/listbgHover.png)" >
            <span class="conName"><a href="<?php the_permalink();?>" title="<?php the_title();?>"><?php the_title();?><span class="red">&nbsp;&nbsp;&nbsp;<?php echo get_post_meta($post->ID,"_red_title",true);?></span></a></span>
            <div class="conTime"><?php the_time('m-d g:i');?></div>
            <div class="clear"></div>
            </div>
		<div class="showLeft">
			<div class="proRightBox">
				<div class="pro1">
					<div class="like">
						<div class="collect">
						  <?php	
						if( $user_ID != '' && $user_ID > 0 ) { 
						$results = $wpdb->get_results("SELECT post FROM wp_userpost_fav WHERE user = $user_ID");
						$user_faves_arr=array();
						foreach($results as $result)
						{
								
								array_push($user_faves_arr,$result->post);
						}	
                        if( !in_array( $post->ID, $user_faves_arr ) ) {
								?>     						
								    <span class="add_fav"><a href="javascript:void(0);" id="<?php echo the_ID(); ?>" title="收藏本文" class="add_to_fav"><?php echo get_post_fav_count($post->ID); ?>     </a></span> 
								
									<?php } else { ?>
								 <span class="add_fav"><a href="javascript:void(0);" id="<?php echo the_ID(); ?>" title="收藏本文" class="add_to_fav"><?php echo get_post_fav_count($post->ID);?> </a></span> 							
									<?php } ?> 
                    
					<?php } else {?>						
						            <span class="add_fav"><a href="javascript:void(0);" id="<?php echo the_ID(); ?>" title="收藏本文" class="add_to_fav_unlogin"><?php echo get_post_fav_count($post->ID);?> </a></span> 
                           
					<?php }	?>	
						</div>
						<div class="commentCount">
							<?php comments_popup_link( '0', '1', '%'); ?>
						</div>
						<div class="clear"></div>
					</div>
					<div class="pro_img">
						<?php
							if( has_post_thumbnail() ){
								echo get_the_post_thumbnail( $post->ID, array(150, 150), array('alt'=>$post->post_title) );
							}else{
								echo '<img src="'.get_post_img( '', 150, 150 ).'" alt="'.$post->post_title .'" width="150" height="150"/>';
							}
							?>
					</div>
					<div class="zhida" id="buy_url_153007">
				                       <a href="<?php echo home_url('/');?>go/<?php echo $post->ID?>" rel="nofollow" class="border_radius_3" target="_blank">直 达 链 接</a>
					<div style="display:none"></div>
					</div>
				</div>
				<div class="mall"><span class="grey">商城：</span><span class="from_val">
				<?php $terms = get_the_terms( $post->ID, 'mall' );
			if ( $terms && ! is_wp_error( $terms ) ) : 
				$draught_links = array();
				foreach ( $terms as $term ) {
					$draught_links[] = $term->name;
					}
				$on_draught = join( ", ", $draught_links );
				echo $on_draught;
			endif; ?>
				</span></div>
			</div>
			<div class="leftShowInfo">
			<span class="has_from_val classified">
					<span class="grey">分类：</span>
					 <?php the_category('，'); ?>
					<span class="post_edit" id='edit-153007'> </span>
			</span>
				<span class="featured">推荐人：<?php if(get_post_meta($post->ID,'_post_author',true)){ echo get_post_meta($post->ID,'_post_author',true); }else{ the_author();} ?></span>				
                <span class="featured"  style="padding-right:5px"><?php edit_post_link(); ?></span>
                
                
                <div class="clear"></div>
			</div>
			<div class="conBox" id="content_420">
				<?php the_content();?>
			</div>
		</div>
		<div class="clear"></div>
		<div class='single_tag'><span class="classified"><span class="grey">标签：</span>
		<?php the_tags('',',','');?></span>
		</div>
		<div class="single_tag">
          <div style=" width:100%; height:20px">
            <?php if (get_previous_post()) { ?>
			  <div class="nav-previous length_page"><span class="grey">上一篇：</span>&nbsp;<?php previous_post_link('%link','%title');?><div class="clear"></div></div>
			<?php } ?>  
          </div>  
          <div >
			<?php if (get_next_post()) { ?>
			<div class="nav-next length_page "><span class="grey">下一篇：</span>&nbsp;<?php next_post_link('%link','%title');?>
			<div class="clear"></div></div>
			<?php } ?>

         </div>     
		</div>
        
        <div class="Score">
              <div style="float:left; padding-top:10px">		
				<?php 
						$voteup = $post->vote_up; 
						$votedown = $post->vote_down;
						$voteall = $voteup + $votedown;
				?>
                    <span  style="float: left; padding:2px 0px 0 0;  width: 75px; background: url(<?php echo get_template_directory_uri();?>/images/like.png) 57px 5px no-repeat; color:#555;">评价本文</span>
                    
					<span class="vote_up"  id="vote_up<?php the_ID(); ?>"><a href="#" title="值得" rel="up_<?php the_ID(); ?>">
					<span  style="width:20px ; margin-left:10px" id="vup<?php the_ID(); ?>"><?php echo $voteup; ?></span></a>人认为值得买！</span>	
                    				
					<span class="vote_down" id="vote_down<?php the_ID(); ?>"><a href="#" title="不值" rel="down_<?php the_ID(); ?>">
                    <span style="width:20px ; margin-left:10px"   id="vdown<?php the_ID(); ?>"><?php echo $votedown; ?></span></a>人认为不值得买！</span>	
                    
                    <span class="allvotes"  id="allvotes<?php the_ID(); ?>">
                    <span id="va<?php the_ID(); ?>"> <?php echo $voteall; ?> </span> 位网友中的
                    <span style="color:#B30B09"  id="vup1<?php the_ID(); ?>"><?php echo $voteup; ?></span> 位认为值得买！
                    </span> 	                
        <script type="text/javascript">

				jQuery( document ).ready( function() {		
				// voting post
				var ue_token = 1;				
				jQuery( '#vote_up<?php the_ID(); ?> a' ).click( function() {		
					
					if(ue_token != 1) {
						alert("您的鼠标点得也太快了吧？！");
						return false;
					}
					ue_token = 0;
				
					var full_info = jQuery( this ).attr( 'rel' );
					var arr_param = full_info.split( '_' );						
					jQuery.post( "<?php echo get_bloginfo( 'template_url' ) ?>/include/vote.php", { act: arr_param[ 0 ], pid: arr_param[ 1 ] }, 
						function( data ) {
							if( data ) {
								var upd_vu = '#vup' + arr_param[ 1 ];
								jQuery( upd_vu ).text( data );
								ue_token = 1;
														
							 	var upd_vu = '#vup1' + arr_param[ 1 ];
								jQuery( upd_vu ).text( data );
								ue_token = 1;
		
								var upd_va = '#va' + arr_param[ 1 ];							
								jQuery( upd_va ).text(<?php echo $voteall+1 ?>);
								ue_token = 1;
								
							}else{
								alert("你已经表过态了！");
								ue_token = 1;
							}
						} );							
					return false;						
				} );	
					
					
				jQuery( '#vote_down<?php the_ID(); ?> a' ).click( function() {	
					
					if(ue_token != 1) {
						alert("您的鼠标点得也太快了吧？！");
						return false;
					}
					ue_token = 0;
								
					var full_info = jQuery( this ).attr( 'rel' );
					var arr_param = full_info.split( '_' );						
					jQuery.post( "<?php echo get_bloginfo( 'template_url' ) ?>/include/vote.php", { act: arr_param[ 0 ], pid: arr_param[ 1 ] }, 
						function( data ) {							
							if( data ) {
								var upd_vd = '#vdown' + arr_param[ 1 ];
								jQuery( upd_vd ).text( data );
								ue_token = 1;
																	
								var upd_va = '#va' + arr_param[ 1 ];;
								jQuery( upd_va ).text( data ) ;
															
								var upd_va = '#va' + arr_param[ 1 ];							
								jQuery( upd_va ).text(<?php echo $voteall+1 ?>);
								ue_token = 1;
													
							}else{		
								ue_token = 1;						
								alert("你已经表过态了！");
							}
						} );						
					return false;						
				} );	
			} );		
			</script>
			</div>
        
              <div style="float:right; padding-top:6px" > 
                <div id="bdshare" class="bdshare_t bds_tools get-codes-bdshare">
                <span style="cursor: pointer; display: block; float: left; height: 18px; color:#666; padding-top:6px; padding-left: 22px; vertical-align:middle "> </span>
                <a class="bds_tsina"></a>
                <a class="bds_tqq"></a>
                <a class="bds_renren"></a>
                <span class="bds_more"></span>
                </div>
            </div>
        </div>
           
           
<div id="comments">
<?php comments_template(); ?>
</div>		
</div>
</div>
<?php endif; ?>
<div class="clear"></div>
<?php
$args=array(
	'orderby'=>'rand',
	'showposts'=>4
);
query_posts($args);
if( have_posts() ) : ?>
<div class="featureContainer">
	<div class="feature">
		<div class="blockScroll">
			<div class="botton-scroll">
				<ul class="featureUL">
				<?php while( have_posts() ) : the_post();?>
				<li class="featureBox">
					<div class="box">
						<?php
							if( has_post_thumbnail() ){
								echo get_the_post_thumbnail( $post->ID, array(150, 150), array('alt'=>$post->post_title) );
							}else{
								echo '<img src="'.get_post_img( '', 150, 150 ).'" alt="'.$post->post_title .'" width="150" height="150"/>';
							}
						?>
					</div>
						<div class="feaName"><a href="<?php the_permalink();?>" title="<?php the_title();?>"><?php the_title();?></a></div>
				</li>
				<?php endwhile; ?>
				</ul>
			</div>
		</div>
		<div class="guessTitle">你可能还喜欢</div>
	</div>
</div>
<?php endif; ?>
<div class="clear"></div>
</div>
</div>
 
</div>
<?php get_sidebar();?>
<div class="clear"></div>
</div>
</section>
<?php get_footer();?>